{{extend './base.html'}}
{{block 'title'}}
话题发布
{{/block}}
{{block 'content'}}
<div class="container">
    <div class="row">
    </div>
</div>
{{/block}}
{{block 'js'}}
    <script>
        $('#topic').on('submit', function (e) {
            e.preventDefault();
            var data = $(this).serialize();
            $.ajax({
                url: '/user/topic',
                type: 'POST',
                data: data,
                dataType: 'json',
                success: function (ret) {
                    if (ret.err_code === 0) {
                        $(this)[0].reset();
                        alert(ret.msg);
                    } else {
                        alert(ret.msg);
                    }
                }.bind($(this)), // 改变this指向
                error: function (err) {
                    alert(err.responseJSON.msg);
                }
            });
        });
    </script>
{{/block}}
